package com.fuyao.cloud.personnel.library.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.fuyao.cloud.common.biz.service.FyBaseServiceImpl;
import com.fuyao.cloud.common.security.service.CloudUser;
import com.fuyao.cloud.common.security.util.SecurityUtils;
import com.fuyao.cloud.personnel.library.entity.BookApply;
import com.fuyao.cloud.personnel.library.mapper.BookApplyMapper;
import com.fuyao.cloud.personnel.library.service.BookApplyService;
import org.springframework.stereotype.Service;

@Service
public class BookApplyServiceImpl extends FyBaseServiceImpl<BookApplyMapper, BookApply> implements BookApplyService {
    @Override
    public void onCreated(BookApply entity) {
        super.onCreated(entity);
        CloudUser user = SecurityUtils.getUser();
        entity.setStatus(0);
        entity.setBorrowerId(user.getId());
        entity.setBorrower(user.getNickname());
    }

    @Override
    public IPage<BookApply> borrowHistory(Page<BookApply> page, Long bookId) {
        return baseMapper.borrowHistory(page, bookId);
    }
}
